package org.skydiveapplibrary.data;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;

import org.skydiveapplibrary.data.RigReminder.DueStatus;

public class Rig
{
	private int id;
	private boolean active;
	private String name = "";
	private boolean primary;
	private boolean archived;
	private int jumpCount;
	private String notes;
	private List<RigComponent> components = new ArrayList<RigComponent>();
	private List<RigReminder> reminders = new ArrayList<RigReminder>();
	private Date lastModifiedUtc;
	private String uniqueId;
	
	public Rig()
	{
		active = true;
	}
	
	public int getId()
	{
		return id;
	}
	public void setId(int id)
	{
		this.id = id;
	}
	public boolean isActive()
	{
		return active;
	}
	public void setActive(boolean active)
	{
		this.active = active;
	}
	public String getName()
	{
		return name;
	}
	public void setName(String name)
	{
		this.name = name;
	}
	public boolean isPrimary()
	{
		return this.primary;
	}
	public void setPrimary(boolean primary)
	{
		this.primary = primary;
	}
	public boolean isArchived()
	{
		return this.archived;
	}
	public void setArchived(boolean archived)
	{
		this.archived = archived;
	}
	public String getNotes()
	{
		return notes;
	}
	public void setNotes(String notes)
	{
		this.notes = notes;
	}
	public int getJumpCount()
	{
		return jumpCount;
	}
	public void setJumpCount(int jumpCount)
	{
		this.jumpCount = jumpCount;
	}
	public List<RigComponent> getComponents()
	{
		return components;
	}
	public List<RigReminder> getReminders()
	{
		return reminders;
	}
	
	public DueStatus getMostUrgentDueStatus()
	{
		DueStatus dueStatus = DueStatus.NotDue;
		for (RigReminder reminder: reminders)
		{
			if (reminder.getDueStatus() == DueStatus.PastDue)
			{
				// return immediately
				return DueStatus.PastDue;
			}
			else if (reminder.getDueStatus() == DueStatus.DueSoon)
			{
				// upgrade to due soon
				dueStatus = DueStatus.DueSoon;
			}
		}
		return dueStatus;
	}
	
	public Date getLastModifiedUtc()
	{
		return lastModifiedUtc;
	}

	public void setLastModifiedUtc(Date lastModifiedUtc)
	{
		this.lastModifiedUtc = lastModifiedUtc;
	}

	public String getUniqueId()
	{
		return uniqueId;
	}
	
	public void setUniqueId(String uniqueId)
	{
		this.uniqueId = uniqueId;
	}
}
